package com.yun.algorithmproblem.leetcode;

public class Leetcode1423 {
    public int maxScore(int[] cardPoints, int k) {
        int max=0;
        int m=cardPoints.length;
        for (int i = 0; i < k; i++) {
            max+=cardPoints[i];
        }
        int cur=max;
        for (int i = 0; i < k; i++) {
            cur-=cardPoints[k-i-1];
            cur+=cardPoints[m-i-1];
            max=Math.max(max,cur);
        }
        return max;
    }

    public static void main(String[] args) {
        int[] cardPoints={1,79,80,1,1,1,200,1};
        int k=3;
        int res=new Leetcode1423().maxScore(cardPoints,k);
        System.out.println(res);
    }
}
